using System;
using System.Collections.Generic;
using System.Text;

namespace OpenPanekitEditor
{
    static class TextConsole
    {
        static List<String> log_list = new List<String>();
        public delegate void WriteLineMethod(String str);
        public delegate void ClearTextMethod();
        static WriteLineMethod add_text_method = null;
        static ClearTextMethod clear_text_method = null;
        public static void WriteLine(String str)
        {
            log_list.Add(str);
            if (add_text_method != null)
            {
                add_text_method(str+"\n");
            }
        }
        public static void FlushText()
        {
            if (add_text_method == null)
                return;
            foreach (String str in log_list)
            {
                add_text_method(str+"\n");
            }
        }
        public static void Clear()
        {
            log_list.Clear();
            if (clear_text_method != null)
            {
                clear_text_method();
            }
        }
        public static void SetWriteLineMethod(WriteLineMethod method)
        {
            add_text_method = method;
        }
        public static void SetClearLineMethod(ClearTextMethod method)
        {
            clear_text_method = method;
        }
    }
}
